﻿using System;
using UnityEngine;

namespace RootMotion.Demos
{
	// Token: 0x020000DB RID: 219
	public abstract class CharacterAnimationBase : MonoBehaviour
	{
		// Token: 0x0600065B RID: 1627 RVA: 0x00006183 File Offset: 0x00004383
		public virtual Vector3 GetPivotPoint()
		{
			return base.transform.position;
		}

		// Token: 0x17000097 RID: 151
		// (get) Token: 0x0600065C RID: 1628 RVA: 0x00003A3D File Offset: 0x00001C3D
		public virtual bool animationGrounded
		{
			get
			{
				return true;
			}
		}

		// Token: 0x0600065D RID: 1629 RVA: 0x00039A88 File Offset: 0x00037C88
		public float GetAngleFromForward(Vector3 worldDirection)
		{
			Vector3 vector = base.transform.InverseTransformDirection(worldDirection);
			return Mathf.Atan2(vector.x, vector.z) * 57.29578f;
		}

		// Token: 0x0600065E RID: 1630 RVA: 0x00039ABC File Offset: 0x00037CBC
		public virtual void Start()
		{
			if (base.transform.parent.GetComponent<CharacterBase>() == null)
			{
				Debug.LogWarning("Animation controllers should be parented to character controllers!", base.transform);
			}
			this.lastPosition = base.transform.position;
			this.localPosition = base.transform.parent.InverseTransformPoint(base.transform.position);
			this.lastRotation = base.transform.rotation;
			this.localRotation = Quaternion.Inverse(base.transform.parent.rotation) * base.transform.rotation;
		}

		// Token: 0x0600065F RID: 1631 RVA: 0x00039B64 File Offset: 0x00037D64
		public virtual void LateUpdate()
		{
			if (this.smoothFollow)
			{
				base.transform.position = Vector3.Lerp(this.lastPosition, base.transform.parent.TransformPoint(this.localPosition), Time.deltaTime * this.smoothFollowSpeed);
				base.transform.rotation = Quaternion.Lerp(this.lastRotation, base.transform.parent.rotation * this.localRotation, Time.deltaTime * this.smoothFollowSpeed);
			}
			this.lastPosition = base.transform.position;
			this.lastRotation = base.transform.rotation;
		}

		// Token: 0x040005A1 RID: 1441
		public bool smoothFollow = true;

		// Token: 0x040005A2 RID: 1442
		public float smoothFollowSpeed = 20f;

		// Token: 0x040005A3 RID: 1443
		public Vector3 lastPosition;

		// Token: 0x040005A4 RID: 1444
		public Vector3 localPosition;

		// Token: 0x040005A5 RID: 1445
		public Quaternion localRotation;

		// Token: 0x040005A6 RID: 1446
		public Quaternion lastRotation;
	}
}
